<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/pages/jyy/jsandcss.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>办理任务</title>
    <script type="application/javascript">
        $(function () {

            toastr.options.positionClass = 'toast-top-center';

            $.post("${pageContext.request.contextPath}/order/order_ByTaskId.do", {taskId: '${param.taskId}'}, function (result) {
                var order = result;
                //订单编号
                $("#number").attr("value", order.number);
                //订单时间
                $("#ordertime").attr("value", order.ordertime);
                //供应商
                $("#remark1").attr("value", order.remark3);
                //金额

                var data = "";
                $.ajax({
                    type: 'POST',
                    async: false,
                    url: '${pageContext.request.contextPath }/oderDetailed/oderDetailedBySumTotal.do',
                    data: 'number=' + order.number,
                    success: function (result) {
                        data = result;
                    }

                });


                $("#total").attr("value", data);

                //id
                $("#oid").attr("value", order.id);

            }, "json");

        });

        function submit(state) {

            if ($("#comments").val().trim().length == 0) {

                toastr.warning("请填写批注!");

                return;
            }


            //发送ajax请求
            $.ajax({
                url: '${pageContext.request.contextPath}/task/manager.do?state=' + state + "&oid=" + $("#oid").val() + "&comments=" + $("#comment").val()+"&taskId="+${param.taskId},
                type: 'POST',
                success: function (result) {
                    var result = eval('(' + result + ')');
                    if (result.success == "1") {

                        toastr.success("操作成功");
                    } else if (result.success == "2") {
                        toastr.warning("审核已提交,请不要重复提交!");

                    } else {
                        toastr.error('操作失败!');
                        return;
                    }
                }
            })

        };

    </script>
</head>
<body>

<form id="form">
    <div class="form-group">
        <label for="number">采购订单号</label>
        <input type="text" class="form-control" id="number">
    </div>
    <div class="form-group">
        <label for="ordertime">订单时间</label>
        <input type="text" class="form-control" id="ordertime" placeholder="Password">
    </div>
    <div class="form-group">
        <label for="remark1">供应商</label>
        <input type="text" class="form-control" id="remark1" placeholder="Password">
    </div>
    <div class="form-group">
        <label for="total">金额</label>
        <input type="text" class="form-control" id="total" placeholder="Password">
        <input type="hidden" id="oid">
    </div>


    <div class="form-group">
        <label for="comments">批注</label>
        <textarea class="form-control" rows="5" id="comments" name="comments"></textarea>
    </div>


    <a href="#" class="btn btn-default" onclick="submit(1)">批准</a>
    <a href="#" class="btn btn-default" onclick="submit(2)">驳回</a>

</form>

</body>
</html>